//
// Created by lenovo on 2024/1/16.
//
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll a, b, c;
    cin >> a >> b;
    c = gcd(a, b);
    vector<ll> e;
    for(ll i = 1;i * i <= c;i++)
    {
        if(c % i == 0)
        {
            cout << i << ' ';
            if(i * i != c)
                e.push_back(c / i);
        }

    }
    for(ll i = e.size() - 1;i >= 0;i--)
    {
        cout << e[i] << ' ';
    }
    return 0;
}